package com.lincoln.cloud.serverclient.interfaces;

import com.lincoln.cloud.common.bean.CommonServerInfo;
import com.lincoln.cloud.common.bean.ServerMessage;

import java.util.List;

/**
 * 基本通信协议
 *
 * @author lincoln
 */
public interface CommunicationProtocol {
    /**
     * 协议初始化
     *
     * @return
     * @throws Exception
     */
    boolean init() throws Exception;

    /**
     * 发送消息
     *
     * @param serverMessage
     * @return
     * @throws Exception
     */
    boolean sendMessage(ServerMessage serverMessage) throws Exception;

    /**
     * 资源服务器登陆
     *
     * @return
     * @throws Exception
     */
    boolean login() throws Exception;

    /**
     * 资源服务器心跳
     *
     * @return
     * @throws Exception
     */
    boolean checkHeart() throws Exception;

    /**
     * 根据app-name获取一个ip
     *
     * @param name
     * @return
     * @throws Exception
     */
    CommonServerInfo achieveServer(String name) throws Exception;

    /**
     * 获取app-name的服务
     *
     * @param name
     * @return
     * @throws Exception
     */
    List<CommonServerInfo> achieveServers(String name) throws Exception;

    /**
     * 通过id查询
     *
     * @param id
     * @return
     * @throws Exception
     */
    CommonServerInfo achieveServer(int id) throws Exception;

    /**
     * 查询所有
     * @return
     * @throws Exception
     */
    List<CommonServerInfo> achieveServers() throws Exception;

    /**
     * 更新信息
     *
     * @return
     * @throws Exception
     */
    boolean updateInfo() throws Exception;


}
